package com.example.boot6rabbitmqbalance.rabbitmq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqConfig {

    @Bean(name = "message")
    public Queue queueMessage() {
        /*
         * 这个步骤就是往rabbitmq的broker里面创建一个队列
         * */
        return new Queue("jack.message.response");
    }
    /*
     * 创建交换器
     * */
    @Bean
    public TopicExchange exchange() {
        return new TopicExchange("exchange.message.response");
    }

    @Bean
    Binding bindingExchangeMessage(@Qualifier("message") Queue queueMessage, TopicExchange exchange) {
        return BindingBuilder.bind(queueMessage).to(exchange).with("jack.message.routeKey.response");
    }
}
